import java.util.*;
public class Test_7_16_3 {
    //字母收集
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        char[][] arr = new char[n+1][m+1];//动态规划都从下标1开始
        for (int i = 1; i <= n; i++) {
            char[] s = in.next().toCharArray();
            for (int j = 1; j <= m ; j++) {
                arr[i][j] = s[j - 1];
            }
        }
        int[][] dp = new int[n+1][m+1];
        //填表
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                int score = 0;
                if (arr[i][j] == 'l'){
                    score = 4;
                }else if (arr[i][j] == 'o'){
                    score = 3;
                }else if (arr[i][j] =='v'){
                    score = 2;
                }else if (arr[i][j] == 'e'){
                    score = 1;
                }
                dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]) + score;
            }
        }
        System.out.println(dp[n][m]);
    }
}